<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<!--只在模块名下面有效 -->
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>信审添加与客户、供应商、挂靠公司有相关的人员</title>
	<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
	<div class="searchArea">
		<form id="searchBar">
			<div class="fieldset1 clearFix">
				<div class="fieldBox">
					<div class="label" style="width: 60px;">姓名</div>
					<div class="field">
						<input name="relaNm" id="relaNm" type="text" class="ui-textbox" value="${cstManualRelation.relaNm}" validate="{required:false}">
					</div>
					<span class="requiredSymbol" style="display: none" >*</span>
				</div>

				<div class="fieldBox">
					<div class="label" style="width: 60px;"> 手机号</div>
					<div class="field">
						<input name="relaPhone" id="relaPhone" type="text" class="ui-textbox" value="${cstManualRelation.relaPhone}" validate="{required:false}">
					</div>
					<span class="requiredSymbol" style="display: none" >*</span>
				</div>

				<div class="fieldBox">
					<div class="label" style="width: 60px;"> 证件号码</div>
					<div class="field">
						<input name="certNo" id="certNo" type="text" class="ui-textbox" value="${cstManualRelation.certNo}" validate="{required:false}">
					</div>
					<span class="requiredSymbol" style="display: none" >*</span>
				</div>

				<div class="clearFix"></div>
				<div class="btnsBox">
					<span id="searchBtn" class="sq-button sq-button-round">查询</span>
					<span onclick="clearBtn();" class="sq-button sq-button-round">清空</span>
					<sys:funcAuth resCd="rggyqx">
						<%-- <span onclick="DtlInfo(null,4,'新增信息');" class="sq-button sq-button-round">新增</span>--%>
						<span  id="addBtn" class="sq-button sq-button-round">新增</span>
					</sys:funcAuth>
					<input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
					<input name="isSignNm" id="isSignId" type="text" style="display: none;" value="0"/>
				</div>
			</div>
		</form>
	</div>
	<div id="ligergridDB" class="sq-grid"></div>
</div>

<script type="text/javascript">
	var cstId='${id}';
	var useType='${useType}';
	var cstType='${cstType}';
	var gridDB = null;
	var pageInApp={}; // to 下一级子窗口 接口
	var loadedTabs=[]
	$(function () {
		initGridDB();//初始化待办列表
		$("#searchBar").ligerForm();
		$("#searchBtn").click(function(event) {
			reloadGrid();
		});


		/* 新增 */
		$("#addBtn").click(function (event) {
			$.ligerDialog.SQopen({
				width: 1050,
				height: 350,
				title: '新增人工干预信息',
				url: '<%=path%>/customer/cstManualRelation/toModifyPage.do?id=null&args=4&cstId='+cstId+'&useType='+useType+'&cstType='+cstType,

				// 自定义buttons的时候 不要设置 fixButtons: true
				buttons: [{
					text: "保存", type: 'ok', cls: 'l-dialog-btn-ok',
					onclick: function (item, Dialog) {
						//在子页面里绑定 frameElement.dialog.onOk = function () {}
						if (Dialog.onOk) {
							Dialog.onOk();
						}
					}
				}, {
					text: "取消", type: 'cancel', cls: 'l-dialog-btn-no',
					onclick: function (item, Dialog) {
						//在子页面里绑定 frameElement.dialog.onCancel = function () {}
						if (Dialog.onCancel) {
							Dialog.onCancel()
						};
					}
				}
				]
			});
		});

	});



	//重新加载GRID
	function reloadGrid(){
		var form = new liger.get("searchBar");
		var data = form.getData();
		for (name in data){
			gridDB.setParm(name,data[name]);
		};
		gridDB.reload();
	}

	//初始化列表
	function initGridDB(){
		if(StringUtils.isEmpty(cstId)){
			$.ligerDialog.SQalert({content: "未找到客户信息！", SQ_type: "error" });
			return false; //验证不通过，不执行以下代码
		}
		$("#ligergridDB").ligerGrid({
			url: '<%=path%>/customer/cstManualRelation/initList.do?cstId='+cstId+'&useType='+useType+'&cstType='+cstType,
			method : 'get',
			columns: [
				{ display: '联系人类型', name: 'relaUserTypeCdNm',  width: 100, enabledSort:false},
				{ display: '姓名', name: 'relaNm',  width: 100, enabledSort:false},
				{ display: '手机号', name: 'relaPhone',  width: 145, enabledSort:false},
				{ display: '证件类型', name: 'certType',  width: 150, enabledSort:false,
					render:function (rowdata, rowindex, value){
						var h="";
						if(StringUtils.isNotEmpty(rowdata.certType)){
							if(1==rowdata.certType){
								h+="身份证";
							}else if(2==rowdata.certType){
								h+="组织机构代码";
							}
						}
						return h;
					}

				},
				{ display: '证件号码', name: 'certNo',  width: 150, enabledSort:false},
				{ display: '备注', name: 'relaNote',  width: 150, enabledSort:false},
				{ display: '创建人', name: 'crtUsrNm',  width: 100, enabledSort:false},
				{ display: '创建时间', name: 'crtTm',  width: 100, enabledSort:false,
					render: function (rowdata, rowindex, value) {
						var h = renderDate2(rowdata.crtTm);
						return h;
					}
				},
				{ display: '操作', width: 150 , align:'left',
					render: function (rowdata, rowindex, value){

						<sys:funcAuth resCd="rggyqx">
						var g='<a class="sq-button-hasicon" href="javascript:DtlInfo(';
						g+="'"+rowdata.id+"',2,'修改信息'";
						g+=');"><i class="sqBtnIco_4"></i>修改</a>  ';

						var d='<a class="sq-button-hasicon" href="javascript:modifyStart(';
						d+="'"+rowdata.id+"',1";
						d+=');"><i class="sqBtnIco_7"></i>删除</a>  ';

						return g+d;
						</sys:funcAuth>
					}
				},
			],
            pageSize:100,
            pageSizeOptions: [10, 20, 30, 40, 50, 100],
            root:'rows',
            record:'total',
            hideLoadButton : true,
            width: '100%',
            height:'100%',
            heightDiff:-30,
            checkbox:true,
            rownumbers:true
        });
        gridDB = liger.get("ligergridDB");
        gridDB.setHeight(100);
        gridDB.options.isSingleCheck=true;
	}


	//查看详细信息
	function DtlInfo (value,args,titles){
		if(StringUtils.isEmpty(cstId)){
			$.ligerDialog.SQalert({content: "未找到客户信息！", SQ_type: "error" });
			return false; //验证不通过，不执行以下代码
		}

		$.ligerDialog.SQopen({
			width: 1050,
			height: 350,
			title: '修改人工干预信息',
			url: '<%=path%>/customer/cstManualRelation/toModifyPage.do?id='+value+'&args='+args+'&cstId='+cstId+'&useType='+useType+'&cstType='+cstType,

			// 自定义buttons的时候 不要设置 fixButtons: true
			buttons: [{
				text: "保存", type: 'ok', cls: 'l-dialog-btn-ok',
				onclick: function (item, Dialog) {
					//在子页面里绑定 frameElement.dialog.onOk = function () {}
					if (Dialog.onOk) {
						Dialog.onOk();
					}
				}
			}, {
				text: "关闭", type: 'cancel', cls: 'l-dialog-btn-no',
				onclick: function (item, Dialog) {
					//在子页面里绑定 frameElement.dialog.onCancel = function () {}
					if (Dialog.onCancel) Dialog.onCancel();
				}
			}
			]
		});

	}

	function redisCallback(msg){
		if(msg.success == 1){
			UIUtils.alertSuccess(msg.data);
		}else{
			UIUtils.alertError(msg.info);
		}
	}

	//删除
	function modifyStart(_id,_isDel){
		if(StringUtils.isEmpty(_id)) return;

		var str='';
		if(_isDel==1){
			str='删除'
		}

		$.ligerDialog.confirm("是否   ‘"+str+"’ 选中的数据?", function (flag) {
			if (flag == false)return;
			var wait_dialog;
			$.ajax({
				type: 'post',
				dataType: 'json',
				data:{ id:_id, isDel:_isDel},
				url: '<%=path%>/customer/cstManualRelation/modify.do',
				beforeSend: function () {
					wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
				},
				success: function (msg) {
					if (msg.success == 1) {
						$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
						gridDB.reload();
						wait_dialog.close();
					} else {
						wait_dialog.close();
						$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
					}
				}
			});
		});
	}



	//格式化时间
	function renderDate2(value) {
		var dateStr = "";
		if (null != value) {
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
		}
		return dateStr;
	}

	function clearBtn(){
		$("#resetBtn").click();  //重置 input-text
		var form = liger.get("searchBar");
		form.setData({  //重置select等特殊表单
			"businessType":" ",
			"bizResCd":" "
		});
	}

	function iframeResize() {
		if (parent.mainApp) {
			parent.mainApp.parentTab.onResize();
		}
	}



</script>

</body>
</html>
